package com.vcredit.creditcat.manager.util;

import com.alibaba.dubbo.config.annotation.Service;
import com.vcredit.creditcat.api.IRegionalismManager;
import com.vcredit.creditcat.dto.RegionalismDto;
import com.vcredit.creditcat.service.SysNationService;
import com.vcredit.creditcat.util.JsonUtil;
import com.vcredit.framework.annotation.Log;
import com.vcredit.framework.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by liaoshengjun on 2017/8/9.
 */
@Service(protocol = { "protocol1" }, version = "1.0")
public class RegionalismManager implements IRegionalismManager{
	@Autowired
	private SysNationService sysNationService;

	/**
	 * 查出所有行政区划
	 * @return
	 * @throws Exception
	 */
	@Log
	@Override
	public Map<String,Object> getAllRegionalisms(String changeStatus) throws Exception{
		Map<String,Object> map=new HashMap<>();
		List<RegionalismDto> regionalismDtoList = sysNationService.getAllRegionalisms();
		String allData=JsonUtil.Obj2Json(regionalismDtoList);
		String encodeData=MD5Util.encode(allData);
		if (encodeData.equals(changeStatus)){
			regionalismDtoList=null;
		}
		map.put("changeStatus",encodeData);
		map.put("areaData",regionalismDtoList);
		return map;
	}
}
